<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;

class PingController extends Controller
{
    //接收评论
    public function getping(Request $request){
        $sid = $request->id;
        $uid = $request->uid;
        $content = $request->contents;
        $res = DB::table('ping')->insert(['single_id'=>$sid,'user_id'=>$uid,'content'=>$content]);
        if ($res != false){
//            var_dump($rec);die;
            return redirect('home/dandetail?id='.$sid);
        }
    }

    //删除评论
    public function delping(){
        $sid = $_GET['sid'];
        $id = $_GET['id'];
        $res = DB::table('ping')->where('id',$id)->delete();
        if ($res != false){
//            var_dump($rec);die;
            return redirect('home/dandetail?id='.$sid);
        }
    }
}
